@extends('Admin.base')

@section('content')
    <style type="text/css" media="screen">
        .lay-dd {
            line-height: 40px;
            height: 40px;
        }

        .layui-con {
            padding-left: 30px;
        }

        .lay-price {
            width: 200px;
            display: inline-block;
        }

        .lay-kk {
            display: inline-block;
            width: 30px;
        }
    </style>
    <div class="layui-card">
        <div class="layui-card-header layuiadmin-card-header-auto">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>员工信息</legend>
            </fieldset>
        </div>
        <div class="layui-card-body">

            <div class="layui-con">
                <div class="layui-row">
                    员工ID：{{$data->number}} <span class="lay-kk"></span>
                    Open ID:{{$data->openid}}<span class="lay-kk"></span>
                </div>
                <div class="layui-row" style="margin-top: 30px;">
                    姓名：{{$data->realname}} <span class="lay-kk"></span>
                    {{$data->status_name}} <span class="lay-kk"></span>
                    部门: {{$data->department_name}} <span class="lay-kk"></span>
                    职位: {{$data->position_name}} <span class="lay-kk"></span>
                    手机号码: {{$data->phone}} <span class="lay-kk"></span>
                    微信号: {{$data->wechat}} <span class="lay-kk"></span>
                </div>
                <div class="layui-row" style="margin-top: 20px;">
                    创建时间：{{$data->created_at}} <span class="lay-kk"></span>
                    离职时间: @if($data->status == 2) {{$data->updated_at}} @else - @endif <span class="lay-kk"></span>
                </div>
                <div class="layui-row" style="margin-top: 20px;">
                    账户余额：{{$data->money_recharge}} <span class="lay-kk"></span>
                    八贝余额: {{$data->money_eight_consh}} <span class="lay-kk"></span>
                    贝壳余额: {{$data->money_consh}} <span class="lay-kk"></span>
                    会员交易完成订单金额: {{$data->total_real_pay}} <span class="lay-kk"></span>
                </div>

                <div class="layui-row" style="margin-top: 60px;">
                    <span class="lay-price">会员数：{{$data->register_user_count}}</span>
                    <button class="layui-btn layui-btn-xs" id="register_user">查看会员</button>
                </div>
                <div class="layui-row" style="margin-top: 30px;">
                    <span class="lay-price">会员订单数：{{$data->orderCount}}</span>
                    <button class="layui-btn layui-btn-xs" id="order_list">查看会员订单</button>
                </div>
                <div class="layui-row" style="margin-top: 30px;">
                    <span class="lay-price">会员充值金额：{{$data->total_recharge}}</span>
                    <button class="layui-btn layui-btn-xs" id="recharge">查看会员充值记录</button>
                </div>
                <br><br><br><br><br>
            </div>
        </div>
    </div>
@endsection





@section('script')
    <script src="/js/ajax.js"></script>
    <script type="text/html" id="userinfo">
        <div>
            @{{d.user_name ? d.user_name : "" }}<br>
            @{{d.user_phone ? d.user_phone : ""}}<br>
            @{{d.user_address ? d.user_address : ""}}
        </div>
    </script>
    <script>
        layui.use(['form', 'element', 'table', 'tableSelect'], function () {
            var $ = layui.$
                , form = layui.form
                , element = layui.element
                , tableSelect = layui.tableSelect
                , table = layui.table;


            //查看邀请的会员
            tableSelect.render({
                elem: '#register_user',  //定义输入框input对象
                width: 1000,
                searchs: 2, //1 开启搜索 2关闭
                table: {    //定义表格参数，与LAYUI的TABLE模块一致，只是无需再定义表格elem
                    url: "{{route('staff.registeruser',['id'=>$data->id])}}",
                    method: "post",
                    cols: [[
                        {field: 'avatar', title: '头像',}
                        , {field: 'info', title: '会员信息',}
                        , {field: 'sex_name', title: '性别',}
                        , {field: 'created_at', title: '注册时间',}
                        , {field: 'user_level_name', title: '会员等级',}
                    ]]
                }
            });

            //查看会员充值记录
            tableSelect.render({
                elem: '#recharge',  //定义输入框input对象
                width: 1000,
                searchs: 2, //1 开启搜索 2关闭
                table: {    //定义表格参数，与LAYUI的TABLE模块一致，只是无需再定义表格elem
                    url: "{{route('staff.recharge',['id'=>$data->id])}}",
                    method: "post",
                    cols: [[
                        {field: 'user_id', title: '用户ID'}
                        , {
                            field: 'user_id',
                            title: '姓名',
                            templet: '<div>@{{d.user_info.realname ? d.user_info.realname : "" }}<br>@{{d.phone ? d.phone : ""}}</div>'
                        }
                        , {field: 'money', title: '变动金额',}
                        , {field: 'balance', title: '变动后余额',}
                        , {field: 'trade_no', title: '流水号',}
                        , {field: 'created_at', title: '创建时间',}
                    ]]
                }
            });


            //查看订单
            var searchstr = '<input style="display:inline-block;width:150px;height:30px;vertical-align:middle;margin-right:-1px;border: 1px solid #C9C9C9;" type="text" name="name" placeholder="会员昵称,手机号码" autocomplete="off" class="layui-input">&nbsp;&nbsp;&nbsp;售卖类型:<select name="type" style="display:inline-block;width:150px;height:30px;vertical-align:middle;margin-right:-1px;border: 1px solid #C9C9C9;"><option value="">全部</option>@foreach (\App\Models\Order::TYPE as $id=>$name )<option value="{{$id}}">{{$name}}</option>@endforeach</select>&nbsp;&nbsp;&nbsp;订单状态:<select name="status" style="display:inline-block;width:150px;height:30px;vertical-align:middle;margin-right:-1px;border: 1px solid #C9C9C9;"><option value="">全部状态</option>@foreach (\App\Models\Order::STSTUS as $id=>$name )<option value="{{$id}}">{{$name}}</option>@endforeach</select>&nbsp;&nbsp;&nbsp;支付方式:<select name="pay_type" style="display:inline-block;width:150px;height:30px;vertical-align:middle;margin-right:-1px;border: 1px solid #C9C9C9;"><option value="">全部支付方式</option>@foreach (\App\Models\Order::PAY_TYPE as $id => $name )<option value="{{$id}}">{{$name}}</option>@endforeach</select>&nbsp;&nbsp;&nbsp;<button class="layui-btn layui-btn-sm layui-btn-primary tableSelect_btn_search" lay-submit lay-filter="tableSelect_btn_search"><i class="layui-icon layui-icon-search"></i></button>';
            tableSelect.render({
                elem: '#order_list',  //定义输入框input对象
                width: 1000,
                searchstr: searchstr,
                table: {    //定义表格参数，与LAYUI的TABLE模块一致，只是无需再定义表格elem
                    url: "{{route('staff.orderlist',['id'=>$data->id])}}",
                    method: "post",
                    cols: [[
                        {field: 'shop_string', title: '商品',}
                        , {field: 'order_no', title: '订单号', width: 100}
                        , {field: 'user_name', title: '买家信息', templet: "#userinfo", width: 120}
                        , {field: 'pay_type_name', title: '支付信息', width: 90}
                        , {field: 'express_string', title: '配送信息', width: 100}
                        , {field: 'status_name', title: '状态', width: 80}
                        , {field: 'created_at', title: '下单时间', width: 120}
                    ]]
                },
                done: function (elem, data) {
                    var id = data.data[0].id;
                    $.ajax({
                        url: "{{route('user.changeinvite',['id'=>$data->id])}}"
                        , type: 'POST'
                        , dataType: 'json'
                        , data: {invite_id: id}
                        , success: function (ret) {
                            if (ret.hasOwnProperty('code') && ret.code == 200) {
                                layer.msg(ret.message, {icon: 1, time: 1000}, function () {
                                    location.reload();
                                });
                                return false;
                            }
                            layer.msg(ret.message, {icon: 2});
                        }
                        , complete: function () {
                            layer.closeAll('loading');
                        }
                    });
                }
            });


        });

    </script>
@endsection